package com.ftt.product.service;



import com.ftt.product.dao.ProductDao;
import com.ftt.product.model.Order;
import com.ftt.product.model.Product;
import com.ftt.product.model.ShoppingCar;

import java.util.List;


public class ProductService {
    //根据编号获取商品
    public Product getProductById(String id) {
        ProductDao dao = new ProductDao();
        Product Product = dao.getProductByID(id);
        return Product;
    }

    public boolean addCar(String customerId, String productId, String number) {
        ProductDao dao = new ProductDao();
        int result = dao.addCar(customerId, productId, number);
        return result == 1;
    }
    public List<ShoppingCar> getShoppingCarInfo(String customerId){
        ProductDao dao = new ProductDao();
        List<ShoppingCar> list = dao.getShoppingCarInfo(customerId);
        return list;
    }
    /*根据会员联系方式来生成订单*/
    public boolean addOrder(String phone, String total_price, List<ShoppingCar> list) {
        ProductDao dao = new ProductDao();
        int num =dao.addOrder(phone,total_price,list);
        return num > 0;
    }
    public List<Order> getOrderList(long phone) {
        ProductDao dao = new ProductDao();
        List<Order> list = dao.getProductOrder(phone);
        return list;
    }
}